home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 1998 November / IRIX 6.5.2 Base Documentation November 1998.img / usr / share / catman / u_man / cat3 / Tcl / incrTcl.z / incrTcl
Text File  |  1998-10-30  |  44KB  |  659 lines

  1.  
  2.  
  3.  
  4. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      incrTcl - Object-oriented extensions to Tcl
  10.  
  11. SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  12.      iiiittttccccllll____ccccllllaaaassssssss _c_l_a_s_s_N_a_m_e {{{{
  13.         iiiinnnnhhhheeeerrrriiiitttt _b_a_s_e_C_l_a_s_s ?_b_a_s_e_C_l_a_s_s...?
  14.         ccccoooonnnnssssttttrrrruuuuccccttttoooorrrr _a_r_g_s _b_o_d_y
  15.         ddddeeeessssttttrrrruuuuccccttttoooorrrr _b_o_d_y
  16.         mmmmeeeetttthhhhoooodddd _n_a_m_e _a_r_g_s _b_o_d_y
  17.         pppprrrroooocccc _n_a_m_e _a_r_g_s _b_o_d_y
  18.         ppppuuuubbbblllliiiicccc _v_a_r_N_a_m_e ?_i_n_i_t? ?_c_o_n_f_i_g?
  19.         pppprrrrooootttteeeecccctttteeeedddd _v_a_r_N_a_m_e ?_i_n_i_t?
  20.         ccccoooommmmmmmmoooonnnn _v_a_r_N_a_m_e ?_i_n_i_t?
  21.      }}}}
  22.  
  23.      _c_l_a_s_s_N_a_m_e _o_b_j_N_a_m_e ?_a_r_g_s...?
  24.      _c_l_a_s_s_N_a_m_e ####aaaauuuuttttoooo ?_a_r_g_s...?
  25.      _c_l_a_s_s_N_a_m_e :::::::: _p_r_o_c ?_a_r_g_s...?
  26.  
  27.      _o_b_j_N_a_m_e _m_e_t_h_o_d ?_a_r_g_s...?
  28.  
  29.      iiiittttccccllll____iiiinnnnffffoooo ccccllllaaaasssssssseeeessss ????_p_a_t_t_e_r_n?
  30.      iiiittttccccllll____iiiinnnnffffoooo oooobbbbjjjjeeeeccccttttssss ????_p_a_t_t_e_r_n? ?----ccccllllaaaassssssss _c_l_a_s_s_N_a_m_e? ?----iiiissssaaaa _c_l_a_s_s_N_a_m_e?
  31.  
  32.      _C_o_m_m_a_n_d_s _a_v_a_i_l_a_b_l_e _w_i_t_h_i_n _c_l_a_s_s _m_e_t_h_o_d_s/_p_r_o_c_s:
  33.      gggglllloooobbbbaaaallll _v_a_r_N_a_m_e ?_v_a_r_N_a_m_e...?
  34.      pppprrrreeeevvvviiiioooouuuussss _c_o_m_m_a_n_d ?_a_r_g_s...?
  35.      vvvviiiirrrrttttuuuuaaaallll _c_o_m_m_a_n_d ?_a_r_g_s...?
  36.  
  37.  
  38. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  39.      [[[[iiiinnnnccccrrrr TTTTccccllll]]]] provides object-oriented extensions to Tcl, much as C++
  40.      provides object-oriented extensions to C.  The emphasis of this work,
  41.      however, is not to create a whiz-bang object-oriented programming
  42.      environment.  Rather, it is to support more structured programming
  43.      practices in Tcl without changing the flavor of the language.  More than
  44.      anything else, [[[[iiiinnnnccccrrrr TTTTccccllll]]]] provides a means of encapsulating related
  45.      procedures together with their shared data in a local namespace that is
  46.      hidden from the outside world.  It encourages better programming by
  47.      promoting the object-oriented "library" mindset.  It also allows for code
  48.      re-use through inheritance.
  49.  
  50.      The fundamental construct in [[[[iiiinnnnccccrrrr TTTTccccllll]]]] is the class definition.  Each
  51.      class acts as a template for actual objects that can be created.  Each
  52.      object in a class contains a unique bundle of data, including "public"
  53.      and "protected" data members.  When execution takes place within the
  54.      scope of the class, both types of data members are accessible.  To the
  55.      programmer working outside of the class scope-using an object to build
  56.      his application-only public data members are accessible.  Public members
  57.      represent attributes that can be used to configure an object.  For
  58.      example, the "-text" attribute in the usual Tk "bbbbuuuuttttttttoooonnnn" widget could be
  59.  
  60.  
  61.                                                                         PPPPaaaaggggeeee 1111
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  69.  
  70.  
  71.  
  72.      thought of as a public member.  Protected members, on the other hand,
  73.      reflect the inner workings of an object and are kept hidden from the
  74.      outside world.  This insulates the programmer that uses a class from the
  75.      details of its implementation.  Classes can also define "common" data
  76.      members that are shared by all objects in a class.  Like protected
  77.      members, common members are only accessible within the scope of the
  78.      class.  The class designer will often provide special class-level
  79.      procedures or "procs" to manipulate common members.  Since these "procs"
  80.      can be invoked without reference to any specific object, they have access
  81.      to common members, but not to public or protected members.
  82.  
  83.      Special procedures called "methods" are used to manipulate individual
  84.      objects.  The use of methods should be familiar to any Tk programmer-the
  85.      "bbbbuuuuttttttttoooonnnn" widget, for example, has methods such as "flash" and "invoke"
  86.      that are used to control its behavior.  These methods form a contract
  87.      between the class designer and the application developer, completely
  88.      specifying the list of functions that can be used to interact with
  89.      objects in the class.  The implementation details within each method,
  90.      however, are left solely to the class designer.  The public interface
  91.      says _w_h_a_t an object will do but not _h_o_w it will do it.  Insulating the
  92.      application developer from these details leaves the class designer free
  93.      to change them at any time, without warning, and without affecting
  94.      programs that rely on the class.  It is precisely this encapsulation that
  95.      makes object-oriented programs easier to understand and maintain.
  96.  
  97.      The fact that [[[[iiiinnnnccccrrrr TTTTccccllll]]]] objects look like Tk widgets is no accident.
  98.      [[[[iiiinnnnccccrrrr TTTTccccllll]]]] was designed this way, to blend naturally into a Tcl/Tk
  99.      application.  But [[[[iiiinnnnccccrrrr TTTTccccllll]]]] extends the Tk paradigm from being merely
  100.      object-based to being fully object-oriented.  An object-oriented system
  101.      supports inheritance, allowing classes to share common behaviors by
  102.      inheriting them from an ancestor or base class.  Having a base class as a
  103.      common abstraction allows a programmer to treat related classes in a
  104.      similar manner.  For example, a toaster and a blender perform different
  105.      (specialized) functions, but both share the abstraction of being
  106.      appliances.  By abstracting common behaviors into a base class, code can
  107.      be _s_h_a_r_e_d rather than _c_o_p_i_e_d.  The resulting application is easier to
  108.      understand and maintain, and derived classes (e.g., specialized
  109.      appliances) can be added or removed more easily.
  110.  
  111.      This description was merely a brief overview of object-oriented
  112.      programming and [[[[iiiinnnnccccrrrr TTTTccccllll]]]].  A more tutorial introduction is presented in
  113.      the paper included with this distribution.  Further details are presented
  114.      in reference form below.
  115.  
  116.  
  117. SSSSCCCCOOOOPPPPEEEE
  118.      Each class maintains its own local scope, separate from the main
  119.      interpreter.  Within the scope of a class, all members-including methods
  120.      and procs, as well as public, protected and common variables-can be
  121.      accessed transparently.  In other words, methods and procs can be used
  122.      like ordinary commands, and variables can be used without declaring them
  123.      with anything like the Tcl "gggglllloooobbbbaaaallll" command.
  124.  
  125.  
  126.  
  127.                                                                         PPPPaaaaggggeeee 2222
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  135.  
  136.  
  137.  
  138.      The scope of a class extends to all derived classes as well, so members
  139.      can be accessed transparently throughout a derivation hierarchy.  If the
  140.      same member name appears more than once in the hierarchy, the class with
  141.      highest priority gets transparent access to the simple member name, and
  142.      all other members must be accessed using the explicit "_c_l_a_s_s::_m_e_m_b_e_r"
  143.      syntax.  Priority is determined by the list of classes as reported by the
  144.      "iiiinnnnffffoooo hhhheeeerrrriiiittttaaaaggggeeee" command.
  145.  
  146.      If a command is not recognized in a particular class scope, it is passed
  147.      up the derivation hierarchy for evaluation.  Again, base classes are
  148.      consulted in the order reported by the "iiiinnnnffffoooo hhhheeeerrrriiiittttaaaaggggeeee" command.  If a
  149.      command is not recognized by any class in the hierarchy, it is passed out
  150.      to the global scope (main interpreter) for evaluation.  This scheme
  151.      allows Tk widget commands, for example, to be accessed transparently
  152.      within any class, but to be executed (as they should be) in the global
  153.      scope.  Any command can be sent explicitly to the global scope using the
  154.      "::_c_o_m_m_a_n_d" syntax.
  155.  
  156.      It is sometimes convenient, particularly when dealing with Tk widgets, to
  157.      have access to global variables that exist in the main interpreter.  This
  158.      is achieved using the usual Tcl "gggglllloooobbbbaaaallll" command within a class method or
  159.      proc.
  160.  
  161.  
  162. AAAARRRRGGGGUUUUMMMMEEEENNNNTTTT LLLLIIIISSSSTTTTSSSS
  163.      Class methods and procs look like ordinary Tcl procs, except that they
  164.      also provide transparent access to class data.  The rules for handling
  165.      formal arguments in the _a_r_g_s lists are the same as well.  Each element of
  166.      this list can be a simple argument name, or another list containing the
  167.      argument name and its default value.  If the last formal argument is
  168.      named "args", it will absorb all unmatched arguments into a single list
  169.      of values.
  170.  
  171.      Argument lists for class methods also recognize a special argument to
  172.      handle configuration of public variables.  If the last formal argument is
  173.      named "config", it will absorb all unmatched arguments and parse them as
  174.      "-_v_a_r_N_a_m_e _v_a_l_u_e" assignments.  If _v_a_r_N_a_m_e is recognized as a public
  175.      variable, then this variable is modified to contain the given value.  If
  176.      the variable was defined with special _c_o_n_f_i_g code, this code is
  177.      automatically executed in the scope of its associated class.  If this
  178.      _c_o_n_f_i_g code returns an error, the variable is automatically reset to its
  179.      previous value, and the method is aborted, returning the configuration
  180.      error.  If argument parsing is successful, the "config" variable is set
  181.      to the list of variables that were configured, and the method body is
  182.      executed.
  183.  
  184.      As an example, suppose that we define a simple class with two public
  185.      variables:
  186.           _iiii_tttt_cccc_llll______cccc_llll_aaaa_ssss_ssss _TTTT_hhhh_iiii_nnnn_gggg _{{{{
  187.               _cccc_oooo_nnnn_ssss_tttt_rrrr_uuuu_cccc_tttt_oooo_rrrr _{{{{_cccc_oooo_nnnn_ffff_iiii_gggg_}}}} _{{{{_}}}}
  188.               _mmmm_eeee_tttt_hhhh_oooo_dddd _cccc_oooo_nnnn_ffff_iiii_gggg_uuuu_rrrr_eeee _{{{{_cccc_oooo_nnnn_ffff_iiii_gggg_}}}} _{{{{_}}}}
  189.  
  190.  
  191.  
  192.  
  193.                                                                         PPPPaaaaggggeeee 3333
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  201.  
  202.  
  203.  
  204.               _pppp_uuuu_bbbb_llll_iiii_cccc _ffff_oooo_oooo _""""_"""" _{{{{ _pppp_uuuu_tttt_ssss _ssss_tttt_dddd_oooo_uuuu_tttt _""""_----_---- _jjjj_uuuu_ssss_tttt _mmmm_oooo_dddd_iiii_ffff_iiii_eeee_dddd _ffff_oooo_oooo_:::: _$$$$_ffff_oooo_oooo_"""" _}}}}
  205.               _pppp_uuuu_bbbb_llll_iiii_cccc _bbbb_aaaa_rrrr _""""_"""" _{{{{ _pppp_uuuu_tttt_ssss _ssss_tttt_dddd_oooo_uuuu_tttt _""""_----_---- _jjjj_uuuu_ssss_tttt _mmmm_oooo_dddd_iiii_ffff_iiii_eeee_dddd _bbbb_aaaa_rrrr_:::: _$$$$_bbbb_aaaa_rrrr_"""" _}}}}
  206.           _}}}}
  207.      Both the constructor and the "configure" method contain the special
  208.      "config" formal argument.  Thus, either of these methods can be used to
  209.      configure the public variables:
  210.           _wwww_iiii_ssss_hhhh_:::: _TTTT_hhhh_iiii_nnnn_gggg _xxxx _----_ffff_oooo_oooo _1111 _----_bbbb_aaaa_rrrr _2222
  211.           _----_---- _jjjj_uuuu_ssss_tttt _mmmm_oooo_dddd_iiii_ffff_iiii_eeee_dddd _ffff_oooo_oooo_:::: _1111
  212.           _----_---- _jjjj_uuuu_ssss_tttt _mmmm_oooo_dddd_iiii_ffff_iiii_eeee_dddd _bbbb_aaaa_rrrr_:::: _2222
  213.           _xxxx
  214.           _wwww_iiii_ssss_hhhh_:::: _xxxx _cccc_oooo_nnnn_ffff_iiii_gggg_uuuu_rrrr_eeee _----_bbbb_aaaa_rrrr _3333
  215.           _----_---- _jjjj_uuuu_ssss_tttt _mmmm_oooo_dddd_iiii_ffff_iiii_eeee_dddd _bbbb_aaaa_rrrr_:::: _3333
  216.      Each time "foo" or "bar" is configured in this example, its special
  217.      _c_o_n_f_i_g code (last argument in the "public" declaration) is executed,
  218.      printing a message to show the updated value.
  219.  
  220.  
  221. CCCCLLLLAAAASSSSSSSS DDDDEEEEFFFFIIIINNNNIIIITTTTIIIIOOOONNNNSSSS
  222.      iiiittttccccllll____ccccllllaaaassssssss _c_l_a_s_s_N_a_m_e _d_e_f_i_n_i_t_i_o_n
  223.           Provides the definition for a class named _c_l_a_s_s_N_a_m_e.  If _c_l_a_s_s_N_a_m_e
  224.           is already defined, then this command returns an error.  If the
  225.           class definition is successfully parsed, _c_l_a_s_s_N_a_m_e becomes a command
  226.           in the interpreter, handling the creation of objects and providing
  227.           access to class scope.  The class _d_e_f_i_n_i_t_i_o_n is evaluated as a
  228.           series of Tcl statements that configure the interpreter managing a
  229.           particular class scope.  In addition to the usual commands, the
  230.           following class definition commands are recognized:
  231.  
  232.           iiiinnnnhhhheeeerrrriiiitttt _b_a_s_e_C_l_a_s_s ?_b_a_s_e_C_l_a_s_s...?
  233.                Declares one or more base classes, causing the current class to
  234.                inherit their characteristics.  Classes must have been defined
  235.                by a previous "iiiittttccccllll____ccccllllaaaassssssss" command, or must be available to the
  236.                auto-loading facility (see "AUTO-LOADING" below).  A single
  237.                class definition can contain no more than one "iiiinnnnhhhheeeerrrriiiitttt"
  238.                command.
  239.  
  240.                When the same member name appears in two or more base classes,
  241.                the base class that appears first in the "iiiinnnnhhhheeeerrrriiiitttt" list takes
  242.                precedence.  For example, if classes "Foo" and "Bar" both
  243.                contain the member "x", then the "iiiinnnnhhhheeeerrrriiiitttt" statement:
  244.                     _iiii_nnnn_hhhh_eeee_rrrr_iiii_tttt _FFFF_oooo_oooo _BBBB_aaaa_rrrr
  245.                allows "Foo::x" to be accessed simply as "x" but forces
  246.                "Bar::x" (and all other inherited members named "x") to be
  247.                referenced with their explicit "_c_l_a_s_s::_m_e_m_b_e_r" name.
  248.  
  249.           ccccoooonnnnssssttttrrrruuuuccccttttoooorrrr _a_r_g_s _b_o_d_y
  250.                Declares the argument list and body used for the constructor,
  251.                which is automatically invoked whenever an object is created.
  252.                If construction is successful, the constructor always returns
  253.                the object name-regardless of how the _b_o_d_y is defined-and the
  254.                object name becomes a command in the main interpreter.  If
  255.                construction fails, an error message is returned.
  256.  
  257.  
  258.  
  259.                                                                         PPPPaaaaggggeeee 4444
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  267.  
  268.  
  269.  
  270.                Like any other method, the constructor can be inherited from a
  271.                base class.  Furthermore, any base class constructor that is
  272.                not explicitly invoked within _b_o_d_y will be implicitly invoked
  273.                by [[[[iiiinnnnccccrrrr TTTTccccllll]]]] in the order that the base classes are reported
  274.                in the "iiiinnnnffffoooo hhhheeeerrrriiiittttaaaaggggeeee" command.  This ensures that all base
  275.                classes are properly constructed.
  276.  
  277.           ddddeeeessssttttrrrruuuuccccttttoooorrrr _b_o_d_y
  278.                Declares the body used for the destructor, which is
  279.                automatically invoked whenever an object is deleted.  If the
  280.                destructor is successful, the object data is destroyed and the
  281.                object name is removed as a command from the main interpreter.
  282.                If destruction fails, an error message is returned and the
  283.                object remains.
  284.  
  285.                Like any other method, the destructor can be inherited from a
  286.                base class.  Furthermore, any base class destructor that is not
  287.                explicitly invoked within _b_o_d_y will be implicitly invoked by
  288.                [[[[iiiinnnnccccrrrr TTTTccccllll]]]], in the _r_e_v_e_r_s_e order compared to constructors.
  289.  
  290.           mmmmeeeetttthhhhoooodddd _n_a_m_e _a_r_g_s _b_o_d_y
  291.                Declares a method called _n_a_m_e with an argument list _a_r_g_s and a
  292.                _b_o_d_y of Tcl statements.  A method is just like the usual Tcl
  293.                "proc" except that it has transparent access to public,
  294.                protected and common variables.  Within the class scope, a
  295.                method can be invoked like any other command-simply by using
  296.                its name.  In the external interpreter, the method name must be
  297.                prefaced by an object name.  Methods in a base class that are
  298.                redefined in the current class or hidden by another base class
  299.                can be explicitly scoped using the "_c_l_a_s_s::_m_e_t_h_o_d" syntax.
  300.  
  301.           pppprrrroooocccc _n_a_m_e _a_r_g_s _b_o_d_y
  302.                Declares a proc called _n_a_m_e with an argument list _a_r_g_s and a
  303.                _b_o_d_y of Tcl statements.  A proc is similar to a method, except
  304.                that it can be invoked without referring to a specific object,
  305.                and therefore has access only to common variables-not to public
  306.                or protected variables.  Within the class scope, a proc can be
  307.                invoked like any other command-simply by using its name.  In
  308.                the external interpreter, the proc is invoked using the
  309.                _c_l_a_s_s_N_a_m_e command "_c_l_a_s_s_N_a_m_e :: _p_r_o_c" to access the class scope
  310.                (see below).  Procs in a base class that are redefined in the
  311.                current class or hidden by another base class can be explicitly
  312.                scoped using the "_c_l_a_s_s::_p_r_o_c" syntax.
  313.  
  314.           ppppuuuubbbblllliiiicccc _v_a_r_N_a_m_e ?_i_n_i_t? ?_c_o_n_f_i_g?
  315.                Declares a public variable named _v_a_r_N_a_m_e.  Public variables are
  316.                visible in methods within the scope of their class and any
  317.                derived class.  In addition, they can be modified outside of
  318.                the class scope using the special "config" formal argument (see
  319.                "ARGUMENT LISTS" above).  If the optional _i_n_i_t is specified, it
  320.                is used as the initial value of the variable when a new object
  321.                is created.  If the optional _c_o_n_f_i_g command is specified, it is
  322.  
  323.  
  324.  
  325.                                                                         PPPPaaaaggggeeee 5555
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  333.  
  334.  
  335.  
  336.                invoked whenever a public variable is modified via the "config"
  337.                formal argument; if the _c_o_n_f_i_g command returns an error, the
  338.                public variable is reset to its value before configuration, and
  339.                the method handling the configuration returns an error.
  340.  
  341.           pppprrrrooootttteeeecccctttteeeedddd _v_a_r_N_a_m_e ?_i_n_i_t?
  342.                Declares a protected variable named _v_a_r_N_a_m_e.  Protected
  343.                variables are visible in methods within the scope of their
  344.                class and any derived class, but cannot be modified outside of
  345.                the class scope.  If the optional _i_n_i_t is specified, it is used
  346.                as the initial value of the variable when a new object is
  347.                created.  Initialization forces the variable to be a simple
  348.                scalar value; uninitialized variables, on the other hand, can
  349.                be used as arrays.  All objects have a built-in protected
  350.                variable named "this" which is initialized to the instance name
  351.                for the object.
  352.  
  353.           ccccoooommmmmmmmoooonnnn _v_a_r_N_a_m_e ?_i_n_i_t?
  354.                Declares a common variable named _v_a_r_N_a_m_e.  Common variables are
  355.                shared among all objects in a class.  They are visible in
  356.                methods and procs in the scope of their class and any derived
  357.                class, but cannot be modified outside of the class scope.  If
  358.                the optional _i_n_i_t is specified, it is used as the initial value
  359.                of the variable.  Initialization forces the variable to be a
  360.                simple scalar value; uninitialized variables, on the other
  361.                hand, can be used as arrays.
  362.  
  363.                Once a common variable has been declared, it can be configured
  364.                using ordinary Tcl code within the class definition.  This
  365.                facility is particularly useful when the initialization of the
  366.                variable is non-trivial - when the variable contains an array
  367.                of values, for example:
  368.                     _iiii_tttt_cccc_llll______cccc_llll_aaaa_ssss_ssss _FFFF_oooo_oooo _{{{{
  369.                          _....
  370.                          _....
  371.                         _cccc_oooo_mmmm_mmmm_oooo_nnnn _bbbb_oooo_oooo_llll_eeee_aaaa_nnnn
  372.                         _ssss_eeee_tttt _bbbb_oooo_oooo_llll_eeee_aaaa_nnnn_((((_tttt_rrrr_uuuu_eeee_)))) _1111
  373.                         _ssss_eeee_tttt _bbbb_oooo_oooo_llll_eeee_aaaa_nnnn_((((_ffff_aaaa_llll_ssss_eeee_)))) _0000
  374.                     _}}}}
  375.  
  376.  
  377. CCCCLLLLAAAASSSSSSSS UUUUSSSSAAAAGGGGEEEE
  378.      When a class definition has been loaded (or made available to the auto-
  379.      loader), it can be used as a command in the main interpreter:
  380.  
  381.      _c_l_a_s_s_N_a_m_e _o_b_j_N_a_m_e ?_a_r_g_s...?
  382.           Creates a new object in class _c_l_a_s_s_N_a_m_e with the name _o_b_j_N_a_m_e.
  383.           Remaining arguments are passed to the constructor.  If construction
  384.           is successful, the object name is returned and this name becomes a
  385.           command in the main interpreter.  Otherwise, an error is returned.
  386.  
  387.  
  388.  
  389.  
  390.  
  391.                                                                         PPPPaaaaggggeeee 6666
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  399.  
  400.  
  401.  
  402.      _c_l_a_s_s_N_a_m_e #auto ?_a_r_g_s...?
  403.           Creates a new object in class _c_l_a_s_s_N_a_m_e with an automatically
  404.           generated name.  Names are of the form _c_l_a_s_s_N_a_m_e<_n_u_m_b_e_r>, e.g.,
  405.           Toaster0, Toaster1, etc.  Remaining arguments are passed to the
  406.           constructor.  If construction is successful, the object name is
  407.           returned and this name becomes a command in the main interpreter.
  408.           Otherwise, an error is returned.
  409.  
  410.      _c_l_a_s_s_N_a_m_e  ::  _p_r_o_c ?_a_r_g_s...?
  411.           Used at the global scope to invoke a class proc named _p_r_o_c.  Class
  412.           procs are like ordinary Tcl procs, except that they are executed in
  413.           the scope of the class and therefore have transparent access to
  414.           common data members.
  415.  
  416.           Notice that, unlike any other scope qualifier in [[[[iiiinnnnccccrrrr TTTTccccllll]]]], the
  417.           "::"  shown above is surrounded by spaces.  This is necessary to
  418.           avoid polluting the global namespace with every possible
  419.           "_c_l_a_s_s::_p_r_o_c" command.  In Release 1.1, a special version of the    |
  420.           usual "unknown" proc was provided to recognize commands like        |
  421.           "_c_l_a_s_s::_p_r_o_c" (without spaces around the "::" qualifier).  This     |
  422.           facility was unpopular, and is no longer supported.  When class     |
  423.           procs are invoked from the main interpreter, the "::" qualifier must|
  424.           be surrounded by spaces.
  425.  
  426.  
  427. OOOOBBBBJJJJEEEECCCCTTTT UUUUSSSSAAAAGGGGEEEE
  428.      _o_b_j_N_a_m_e _m_e_t_h_o_d ?_a_r_g_s...?
  429.           Invokes a method named _m_e_t_h_o_d to operate on the specified object.
  430.           Remaining arguments are passed to the method.  The method name can
  431.           be "constructor", "destructor", any method name appearing in the
  432.           class definition, or any of the following built-in methods.
  433.  
  434. BBBBUUUUIIIILLLLTTTT----IIIINNNN MMMMEEEETTTTHHHHOOOODDDDSSSS
  435.      _o_b_j_N_a_m_e iiiissssaaaa _c_l_a_s_s_N_a_m_e
  436.           Returns non-zero if the given _c_l_a_s_s_N_a_m_e can be found in the object's
  437.           heritage, and zero otherwise.
  438.  
  439.      _o_b_j_N_a_m_e ddddeeeelllleeeetttteeee
  440.           Invokes the destructor associated with an object.  If the destructor
  441.           is successful, data associated with the object is deleted and
  442.           _o_b_j_N_a_m_e is removed from the commands in the main interpreter.
  443.           Returns the empty string, regardless of the destructor body.
  444.  
  445.      _o_b_j_N_a_m_e iiiinnnnffffoooo _o_p_t_i_o_n ?_a_r_g_s...?
  446.  
  447.      _c_l_a_s_s_N_a_m_e :: iiiinnnnffffoooo _o_p_t_i_o_n ?_a_r_g_s...?
  448.           Returns information related to the class definition, or information
  449.           concerning the interpreter that implements the class scope.  The
  450.           _o_p_t_i_o_n parameter includes the following things, as well as the
  451.           options recognized by the usual Tcl "info" command:
  452.  
  453.  
  454.  
  455.  
  456.  
  457.                                                                         PPPPaaaaggggeeee 7777
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  465.  
  466.  
  467.  
  468.           _o_b_j_N_a_m_e iiiinnnnffffoooo ccccllllaaaassssssss
  469.                Returns the class name at the current class scope.  When
  470.                prefaced by the object name, this command executes in the
  471.                most-specific class scope, and therefore returns the most-
  472.                specific class name.
  473.  
  474.           _o_b_j_N_a_m_e iiiinnnnffffoooo iiiinnnnhhhheeeerrrriiiitttt
  475.                Returns the list of base classes as they were defined in the
  476.                "iiiinnnnhhhheeeerrrriiiitttt" command, or an empty string if this is a top-level
  477.                class.
  478.  
  479.           _o_b_j_N_a_m_e iiiinnnnffffoooo hhhheeeerrrriiiittttaaaaggggeeee
  480.                Returns the current class name and the entire list of base
  481.                classes in the order that they are traversed for object
  482.                construction or member lookup.
  483.  
  484.           _o_b_j_N_a_m_e iiiinnnnffffoooo mmmmeeeetttthhhhoooodddd
  485.  
  486.           _o_b_j_N_a_m_e iiiinnnnffffoooo mmmmeeeetttthhhhoooodddd _m_e_t_h_o_d_N_a_m_e ?----aaaarrrrggggssss? ?----bbbbooooddddyyyy?
  487.                In the first form, this command returns a list of all class
  488.                methods.  In the second form, it returns information for a
  489.                specific method.  If neither of the optional ----aaaarrrrggggssss or ----bbbbooooddddyyyy
  490.                flags is specified, a complete method definition is returned as
  491.                a list of three elements including the method name, argument
  492.                list and body.  Otherwise, the requested information is
  493.                returned without the method name.  If the _m_e_t_h_o_d_N_a_m_e is not
  494.                recognized, an empty string is returned.
  495.  
  496.           _o_b_j_N_a_m_e iiiinnnnffffoooo pppprrrroooocccc
  497.  
  498.           _o_b_j_N_a_m_e iiiinnnnffffoooo pppprrrroooocccc _p_r_o_c_N_a_m_e ?----aaaarrrrggggssss? ?----bbbbooooddddyyyy?
  499.                In the first form, this command returns a list of all class
  500.                procs.  In the second form, it returns information for a
  501.                specific proc.  If neither of the optional ----aaaarrrrggggssss or ----bbbbooooddddyyyy flags
  502.                is specified, a complete proc definition is returned as a list
  503.                of three elements including the proc name, argument list and
  504.                body.  Otherwise, the requested information is returned without
  505.                the proc name.  If the _p_r_o_c_N_a_m_e is not recognized, an empty
  506.                string is returned.
  507.  
  508.           _o_b_j_N_a_m_e iiiinnnnffffoooo ppppuuuubbbblllliiiicccc
  509.  
  510.           _o_b_j_N_a_m_e iiiinnnnffffoooo ppppuuuubbbblllliiiicccc _v_a_r_N_a_m_e ?----iiiinnnniiiitttt? ?----vvvvaaaalllluuuueeee? ?----ccccoooonnnnffffiiiigggg?
  511.                In the first form, this command returns a list of all public
  512.                variables.  In the second form, it returns information for a
  513.                specific public variable.  If none of the optional ----iiiinnnniiiitttt,
  514.                ----vvvvaaaalllluuuueeee or ----ccccoooonnnnffffiiiigggg flags are specified, all available
  515.                information is returned as a list of four elements including
  516.                the variable name, initial value, current value, and
  517.                configuration commands.  Otherwise, the requested information
  518.                is returned without the variable name.  If the _v_a_r_N_a_m_e is not
  519.                recognized, an empty string is returned.
  520.  
  521.  
  522.  
  523.                                                                         PPPPaaaaggggeeee 8888
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  531.  
  532.  
  533.  
  534.           _o_b_j_N_a_m_e iiiinnnnffffoooo pppprrrrooootttteeeecccctttteeeedddd
  535.  
  536.           _o_b_j_N_a_m_e iiiinnnnffffoooo pppprrrrooootttteeeecccctttteeeedddd _v_a_r_N_a_m_e ?----iiiinnnniiiitttt? ?----vvvvaaaalllluuuueeee?
  537.                In the first form, this command returns a list of all protected
  538.                variables.  In the second form, it returns information for a
  539.                specific protected variable.  If neither of the optional ----iiiinnnniiiitttt
  540.                or ----vvvvaaaalllluuuueeee flags is specified, all available information is
  541.                returned as a list of three elements including the variable
  542.                name, initial value and current value.  Otherwise, the
  543.                requested information is returned without the variable name.
  544.                If the _v_a_r_N_a_m_e is not recognized, an empty string is returned.
  545.  
  546.           _o_b_j_N_a_m_e iiiinnnnffffoooo ccccoooommmmmmmmoooonnnn
  547.  
  548.           _o_b_j_N_a_m_e iiiinnnnffffoooo ccccoooommmmmmmmoooonnnn _v_a_r_N_a_m_e ?----iiiinnnniiiitttt? ?----vvvvaaaalllluuuueeee?
  549.                In the first form, this command returns a list of all common
  550.                variables.  In the second form, it returns information for a
  551.                specific common variable.  If neither of the optional ----iiiinnnniiiitttt or
  552.                ----vvvvaaaalllluuuueeee flags is specified, all available information is
  553.                returned as a list of three elements including the variable
  554.                name, initial value and current value.  Otherwise, the
  555.                requested information is returned without the variable name.
  556.                If the _v_a_r_N_a_m_e is not recognized, an empty string is returned.
  557.  
  558. CCCCLLLLAAAASSSSSSSS////OOOOBBBBJJJJEEEECCCCTTTT IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  559.      The following commands are available at the global scope to query
  560.      information about classes and objects that have been created.
  561.  
  562.      iiiittttccccllll____iiiinnnnffffoooo ccccllllaaaasssssssseeeessss ????_p_a_t_t_e_r_n?
  563.           Returns a list of classes with names matching the string _p_a_t_t_e_r_n
  564.           according to the rules of the "ssssttttrrrriiiinnnngggg mmmmaaaattttcccchhhh" command.  If _p_a_t_t_e_r_n is
  565.           not specified, returns a list of all known classes.
  566.  
  567.      iiiittttccccllll____iiiinnnnffffoooo oooobbbbjjjjeeeeccccttttssss ????_p_a_t_t_e_r_n? ?----ccccllllaaaassssssss _c_l_a_s_s_N_a_m_e? ?----iiiissssaaaa _c_l_a_s_s_N_a_m_e?
  568.           Returns a list of objects with names matching the string _p_a_t_t_e_r_n
  569.           according to the rules of the "ssssttttrrrriiiinnnngggg mmmmaaaattttcccchhhh" command.  If _p_a_t_t_e_r_n is
  570.           not specified, return a list of all known objects.  If the "----ccccllllaaaassssssss"
  571.           parameter is specified, this list is restricted to objects whose
  572.           most-specific class is _c_l_a_s_s_N_a_m_e.  If the "----iiiissssaaaa" parameter is
  573.           specified, this list is further restricted to objects having the
  574.           given _c_l_a_s_s_N_a_m_e anywhere in their heritage.
  575.  
  576. OOOOTTTTHHHHEEEERRRR BBBBUUUUIIIILLLLTTTT----IIIINNNN CCCCOOOOMMMMMMMMAAAANNNNDDDDSSSS
  577.      The following commands are also available within the scope of each class.
  578.      They cannot be accessed from outside of the class as proper methods or
  579.      procs; rather, they are useful inside the class when implementing its
  580.      functionality.
  581.  
  582.      gggglllloooobbbbaaaallll _v_a_r_N_a_m_e ?_v_a_r_N_a_m_e...?
  583.           Creates a link to one or more global variables in the main
  584.           interpreter.  This is useful when communicating with Tk widgets that
  585.           rely on global variables.
  586.  
  587.  
  588.  
  589.                                                                         PPPPaaaaggggeeee 9999
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596. iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))                                                    iiiinnnnccccrrrrTTTTccccllll((((3333TTTTccccllll))))
  597.  
  598.  
  599.  
  600.      pppprrrreeeevvvviiiioooouuuussss _c_o_m_m_a_n_d ?_a_r_g_s...?
  601.           Invokes _c_o_m_m_a_n_d in the scope of the most immediate base class (i.e.,|
  602.           the "previous" class) for the object.  For classes using single
  603.           inheritance, this facility can be used to avoid hard-wired base
  604.           class references of the form "_c_l_a_s_s::_c_o_m_m_a_n_d", making code easier to
  605.           maintain.  For classes using multiple inheritance, the utility of
  606.           this function is dubious.  If the class at the relevant scope has no
  607.           base class, an error is returned.
  608.  
  609.      vvvviiiirrrrttttuuuuaaaallll _c_o_m_m_a_n_d ?_a_r_g_s...?
  610.           Invokes _c_o_m_m_a_n_d in the scope of the most-specific class for the     |
  611.           object.  This provides a way of accessing "virtual" functions from  |
  612.           within class methods.  Normally, the commands at a certain class    |
  613.           scope refer to methods/procs in that class or in less-specific base |
  614.           classes upward in the hierarchy.  The vvvviiiirrrrttttuuuuaaaallll command moves the     |
  615.           scope _d_o_w_n_w_a_r_d to the most-specific class in the hierarchy, and then|
  616.           invokes the method.  If a class has methods that are redefined in   |
  617.           derived classes, this causes the most-specific method to be invoked.|
  618.           Note that this is only needed when commands are invoked from within |
  619.           a class; when commands are invoked at the global scope, they are    |
  620.           automatically executed in the scope of the most-specific class.
  621.  
  622.  
  623. AAAAUUUUTTTTOOOO----LLLLOOOOAAAADDDDIIIINNNNGGGG
  624.      Class definitions need not be loaded explicitly; they can be loaded as
  625.      needed by the usual Tcl auto-loading facility.  Each directory containing
  626.      class definition files should have an accompanying "tclIndex" file.  Each
  627.      line in this file identifies a Tcl procedure _o_r [_i_n_c_r _T_c_l] _c_l_a_s_s
  628.      _d_e_f_i_n_i_t_i_o_n and the file where the definition can be found.
  629.  
  630.      For example, suppose a directory contains the definitions for classes
  631.      "Toaster" and "SmartToaster".  Then the "tclIndex" file for this
  632.      directory would look like:
  633.           _#### _TTTT_cccc_llll _aaaa_uuuu_tttt_oooo_llll_oooo_aaaa_dddd _iiii_nnnn_dddd_eeee_xxxx _ffff_iiii_llll_eeee_:::: _eeee_aaaa_cccc_hhhh _llll_iiii_nnnn_eeee _iiii_dddd_eeee_nnnn_tttt_iiii_ffff_iiii_eeee_ssss _aaaa _TTTT_cccc_llll
  634.           _#### _pppp_rrrr_oooo_cccc_eeee_dddd_uuuu_rrrr_eeee _oooo_rrrr _[[[[_iiii_nnnn_cccc_rrrr _TTTT_cccc_llll_]]]] _cccc_llll_aaaa_ssss_ssss _aaaa_nnnn_dddd _tttt_hhhh_eeee _ffff_iiii_llll_eeee _wwww_hhhh_eeee_rrrr_eeee _tttt_hhhh_aaaa_tttt
  635.           _#### _eeee_nnnn_tttt_iiii_tttt_yyyy _iiii_ssss _dddd_eeee_ffff_iiii_nnnn_eeee_dddd_....
  636.           _TTTT_oooo_aaaa_ssss_tttt_eeee_rrrr _TTTT_oooo_aaaa_ssss_tttt_eeee_rrrr_...._tttt_cccc_llll
  637.           _SSSS_mmmm_aaaa_rrrr_tttt_TTTT_oooo_aaaa_ssss_tttt_eeee_rrrr _SSSS_mmmm_aaaa_rrrr_tttt_TTTT_oooo_aaaa_ssss_tttt_eeee_rrrr_...._tttt_cccc_llll
  638.      The auto-loader must be made aware of this directory by appending the
  639.      directory name to the "auto_path" variable.  When this is in place,
  640.      classes will be auto-loaded as needed when used in an application.
  641.  
  642.      Note: the usual "auto_mkindex" procedure used to generate the "tclIndex"
  643.      file does not, by default, recognize [[[[iiiinnnnccccrrrr TTTTccccllll]]]] class definitions;
  644.      however, it can be modified to do so.  Such a modification is included in
  645.      the "library" directory in the usual distribution for [[[[iiiinnnnccccrrrr TTTTccccllll]]]].
  646.  
  647.  
  648. KKKKEEEEYYYYWWWWOOOORRRRDDDDSSSS
  649.      object-oriented, class
  650.  
  651.  
  652.  
  653.  
  654.  
  655.                                                                        PPPPaaaaggggeeee 11110000
  656.  
  657.  
  658.  
  659.